﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LiXiangList.aspx.cs" Inherits="PropertyAppraisal.LiXiangList" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="../easyui/easyui/1.3.2/themes/default/easyui.css" />

    <link href="../easyui/easyui/1.3.2/themes/icon.css" rel="stylesheet" />
    <script src="../easyui/easyui/1.3.2/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="../easyui/easyui/1.3.2/jquery.easyui.min.js"></script>
    <script src="../easyui/easyui/1.3.2/easyloader.js"></script>
    <script src="../easyui/easyui/1.3.2/locale/easyui-lang-zh_CN.js"></script>

    <%--转换时间格式--%>
     <script src="../Tools/TimeJs.js"></script>
</head>
<body>
    <div fit="true">
        <div style="padding: 3px">
            <a href="javascript:void(0) " class="easyui-linkbutton" data-options="iconCls:'icon-add',toggle:true" onclick="dengji()">登记</a>
            <%--<select class="easyui-combobox" id="select1">
                <option>所属部门</option>
            </select>

            <select class="easyui-combobox" id="select2">
                <option>请选择</option>
            </select>
            <a href="#" class="easyui-linkbutton" plain="true" onclick="doSearch()">查询</a>--%>
        </div>
            <iframe width="0" height="0" src="../SessionKeeper.aspx"></iframe>   
        <table id="dg" title="项目立项列表" style="width: 1190px; height: 600px" data-options="
				rownumbers:true,
				singleSelect:true,
				autoRowHeight:false,
				pagination:true,
				pageSize:10">
            <thead>
                <tr>
                    <th field="inv" width="110" align="center">项目号</th>
                    <th field="date" width="150" align="center">所属部门</th>
                    <th field="name" width="110" align="center">借款人</th>
                    <th field="amount" width="110" align="center">借款人电话</th>
                    <th field="price" width="110" align="center">贷款额度</th>
                    <th field="cost" width="150" align="center">登记日期</th>
                    <th field="note" width="170" align="center">项目状态</th>
                    <th field="cao" width="170" align="center">操作</th>
                </tr>
            </thead>
        </table>
    </div>
    <script type="text/javascript">

        //function doSearch() {
        //    $('#tt').datagrid('load', {
        //        itemid: $('#itemid').val(),
        //        productid: $('#productid').val()
        //    });
        //}

        //跳转项目立项登记页面
        function dengji() {
            $('#wu-tabs').tabs('close', '项目立项列表');
            parent.addTab("项目立项登记", "/ProjectInitiation/LiXiangRegistered.aspx", "icon-chart-organisation", true);
        }

        //绑定数据表格
        function getData() {
            var rows = [];
            $.ajax({
                type: "post", //要用post方式                 
                url: "LiXiangList.aspx/showDeng",//方法所在页面和方法名
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: false,
                success: function (result) {
                    var json = eval("(" + result.d + ")");

                    for (var i = 0; i < json.length; i++) {
                        rows.push({
                            inv: json[i].projectNumber,
                            date: json[i].department_Name, //$.fn.datebox.defaults.formatter(new Date()),
                            name: json[i].loan_Name,
                            amount: json[i].loan_TEL,
                            price: json[i].basic_Quota,
                            cost: (new Date(json[i].basic_CreateTime)).Format("yyyy-M-d h:m:s.S"),
                            note: json[i].basic_State == 0 ? "保存未提交" : json[i].basic_State == 1 ? "已提交/待勘察" : json[i].basic_State == 2 ? "勘察中" : json[i].basic_State == 3 ? "已勘察/待评估" : json[i].basic_State == 4 ? "评估进行中" : json[i].basic_State == 5 ? "已评估/待初审" : json[i].basic_State == 6 ? "初审未通过" : json[i].basic_State == 7 ? "初审通过" : json[i].basic_State == 8 ? "终审未通过" : "终审通过",
                            cao: json[i].basic_State == 0 ? '<a HREF = "#" class= "easyui-linkbutton" onclick=\"Edit(' + json[i].projectNumber + ',' + json[i].basic_State + ') \" > 提交</a> '
                                : json[i].basic_State > 0 & json[i].basic_State <= 3 ? '<a HREF = "#" class= "easyui-linkbutton" onclick=\"Edit(' + json[i].projectNumber + ',' + json[i].basic_State + ')\"> 编辑</a> ' :
                                json[i].basic_State == 3 ? '<a HREF = "#" class= "easyui-linkbutton" onclick=\"Edit(' + json[i].projectNumber + ',' + json[i].basic_State + ')\"> 编辑</a> ' :
                                json[i].basic_State > 3 & json[i].basic_State < 5 ? '<a HREF = "#" class= "easyui-linkbutton" onclick=\"Edit(' + json[i].projectNumber + ',' + json[i].basic_State + ')\"> 编辑</a> '
                                : json[i].basic_State == 9 ? '<a HREF = "#" class= "easyui-linkbutton" onclick=\"daochu(' + json[i].projectNumber + ')\"> 导出</a>' :
                                json[i].basic_State == 5 ? "" : null,
                        }); 
                    }
                }
            })
            return rows;
        }

        //跳转修改评估员
        function Edit(obj,state) {
            parent.addTab("修改评估员", "/ProjectInitiation/LiXiangEdit.aspx?ke=" + obj + "&state="+state, "icon-chart-organisation", true);
        }
        function pagerFilter(data) {
            if (typeof data.length == 'number' && typeof data.splice == 'function') {	// is array
                data = {
                    total: data.length,
                    rows: data
                }
            }
            var dg = $(this);
            var opts = dg.datagrid('options');
            var pager = dg.datagrid('getPager');
            pager.pagination({
                onSelectPage: function (pageNum, pageSize) {
                    opts.pageNumber = pageNum;
                    opts.pageSize = pageSize;
                    pager.pagination('refresh', {
                        pageNumber: pageNum,
                        pageSize: pageSize
                    });
                    dg.datagrid('loadData', data);
                },
                onRefresh: function (pageNum, pageSize) {
                    $('#dg').datagrid({ loadFilter: pagerFilter }).datagrid('loadData', getData());
                }
            });
            if (!data.originalRows) {
                data.originalRows = (data.rows);
            }
            var start = (opts.pageNumber - 1) * parseInt(opts.pageSize);
            var end = start + parseInt(opts.pageSize);
            data.rows = (data.originalRows.slice(start, end));
            return data;
        }

        $(function () {
            
            $('#dg').datagrid({ loadFilter: pagerFilter }).datagrid('loadData', getData());
            
        });
        
        //导出
        function daochu(id) {
            $.ajax({
                type: "post", //要用post方式                 
                url: "LiXiangList.aspx/daochu",//方法所在页面和方法名
                data: "{ 'id': '" + id + "' }",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                async: false,
                success: function (result) {
                    if (result != null)
                    {
                        alert("导出成功");
                        location.href = '' + result.d + ''
                    }
                    else
                        alert("导出失败");            
                }
            })
        }
    </script>
</body>
</html>


